/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojos;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author A7med Kotb
 */
@Entity
@Table(name = "expenses")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Expenses.findAll", query = "SELECT e FROM Expenses e"),
    @NamedQuery(name = "Expenses.findByExpId", query = "SELECT e FROM Expenses e WHERE e.expId = :expId"),
    @NamedQuery(name = "Expenses.findByExpenseType", query = "SELECT e FROM Expenses e WHERE e.expenseType = :expenseType"),
    @NamedQuery(name = "Expenses.findByExpenseDate", query = "SELECT e FROM Expenses e WHERE e.expenseDate between :fromDate and :toDate"),
    @NamedQuery(name = "Expenses.findByEmployeeandDate", query = "SELECT e FROM Expenses e WHERE e.employee = :employee and e.expenseDate between :fromDate and :toDate"),
    @NamedQuery(name = "Expenses.findByTask", query = "SELECT e FROM Expenses e WHERE e.task = :task"),
    @NamedQuery(name = "Expenses.findByEmployee", query = "SELECT e FROM Expenses e WHERE e.employee = :employee"),
    @NamedQuery(name = "Expenses.findByReimbursable", query = "SELECT e FROM Expenses e WHERE e.reimbursable = :reimbursable"),
    @NamedQuery(name = "Expenses.findByUnits", query = "SELECT e FROM Expenses e WHERE e.units = :units"),
    @NamedQuery(name = "Expenses.findByCreatedAt", query = "SELECT e FROM Expenses e WHERE e.createdAt = :createdAt"),
    @NamedQuery(name = "Expenses.deleteByExpId", query = "delete FROM Expenses e WHERE e.expId = :expId"),
    @NamedQuery(name = "Expenses.findByStatus", query = "SELECT e FROM Expenses e WHERE e.status = :status"),
    @NamedQuery(name = "Expenses.findByprojectId", query = "SELECT e FROM Expenses e WHERE e.project = :project and e.reimbursable = :reimbursable")})
public class Expenses implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "expense_date")
    @Temporal(TemporalType.DATE)
    private Date expenseDate;
    @Size(max = 255)
    @Column(name = "created_at")
    private String createdAt;
    @Size(max = 255)
    @Column(name = "comment")
    private String comment;
    @Column(name = "expense_amount")
    private Integer expenseAmount;
    @Column(name = "expense_total")
    private Integer expenseTotal;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "exp_id")
    private Integer expId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "expense_type")
    private String expenseType;
    @Basic(optional = false)
    @Size(min = 1, max = 45)
    @Column(name = "task")
    private String task;
    @Basic(optional = false)
    @Column(name = "reimbursable")
    private boolean reimbursable;
    @Column(name = "units")
    private Integer units;
    @Basic(optional = false)
    @Size(min = 1, max = 45)
    @Column(name = "status")
    private String status="saved";
    @JoinColumn(name = "project", referencedColumnName = "pro_id")
    @ManyToOne
    private Projects project;
    @JoinColumn(name = "employee", referencedColumnName = "emp_id")
    @ManyToOne
    private Employees employee;
    @JoinColumn(name = "currency", referencedColumnName = "curr_id")
    @ManyToOne(optional = false)
    private Currencies currency;
    @JoinColumn(name = "created_by", referencedColumnName = "emp_id")
    @ManyToOne
    private Employees createdBy;
    
    public Expenses() {
    }

    public Expenses(Integer expId) {
        this.expId = expId;
    }

    public Expenses(Integer expId, String expenseType, Date expenseDate, String task, boolean reimbursable,String createdAt, String status) {
        this.expId = expId;
        this.expenseType = expenseType;
        this.expenseDate = expenseDate;
        this.task = task;
        this.reimbursable = reimbursable;
        this.createdAt = createdAt;
        this.status = status;
    }

    public Integer getExpId() {
        return expId;
    }

    public void setExpId(Integer expId) {
        this.expId = expId;
    }

    public String getExpenseType() {
        return expenseType;
    }

    public void setExpenseType(String expenseType) {
        this.expenseType = expenseType;
    }

    public Date getExpenseDate() {
        return expenseDate;
    }

    public void setExpenseDate(Date expenseDate) {
        this.expenseDate = expenseDate;
    }

    public String getTask() {
        return task;
    }

    public void setTask(String task) {
        this.task = task;
    }

    public boolean getReimbursable() {
        return reimbursable;
    }

    public void setReimbursable(boolean reimbursable) {
        this.reimbursable = reimbursable;
    }   

    public Integer getUnits() {
        return units;
    }

    public void setUnits(Integer units) {
        this.units = units;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Projects getProject() {
        return project;
    }

    public void setProject(Projects project) {
        this.project = project;
    }

    public Employees getEmployee() {
        return employee;
    }

    public void setEmployee(Employees employee) {
        this.employee = employee;
    }

    public Currencies getCurrency() {
        return currency;
    }

    public void setCurrency(Currencies currency) {
        this.currency = currency;
    }

    public Employees getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Employees createdBy) {
        this.createdBy = createdBy;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (expId != null ? expId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Expenses)) {
            return false;
        }
        Expenses other = (Expenses) object;
        if ((this.expId == null && other.expId != null) || (this.expId != null && !this.expId.equals(other.expId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pojos.Expenses[ expId=" + expId + " ]";
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Integer getExpenseAmount() {
        return expenseAmount;
    }

    public void setExpenseAmount(Integer expenseAmount) {
        this.expenseAmount = expenseAmount;
    }

    public Integer getExpenseTotal() {
        return expenseTotal;
    }

    public void setExpenseTotal(Integer expenseTotal) {
        this.expenseTotal = expenseTotal;
    }
    
}
